refactor: consolidate cluster slot checks in connection.rs - #73
Merged
Conversation
extract a single `cluster_slot_check()` function that pattern-matches the command to find its routing key(s), performs slot ownership and crossslot validation, and returns the redirect/error frame if needed. this replaces ~35 identical 3-line check blocks in single-key command arms and 4 similar 7-line blocks in multi-key arms with one call at the top of `execute()`, removing ~130 lines of repeated boilerplate.
kacy
added a commit
that referenced
this pull request
Feb 11, 2026
extract a single `cluster_slot_check()` function that pattern-matches the command to find its routing key(s), performs slot ownership and crossslot validation, and returns the redirect/error frame if needed. this replaces ~35 identical 3-line check blocks in single-key command arms and 4 similar 7-line blocks in multi-key arms with one call at the top of `execute()`, removing ~130 lines of repeated boilerplate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
summary
extracts a single
cluster_slot_check()function that pattern-matches the command to determine its routing key(s), validates slot ownership and crossslot constraints, and returns the redirect/error frame if needed. this replaces the per-command inline checks with one call at the top ofexecute().check_cluster_slot) and 7-line (check_crossslot+check_cluster_slot) blocks scattered across ~39 match armswhat was tested
cargo build -p ember-server— compiles cleancargo clippy --workspace -- -D warnings— no warningscargo test --workspace— all tests pass (behavior unchanged)design considerations
the new function uses a single match on
&Commandto extract the routing key(s), grouping commands into four categories:ref key— delegates tocluster.check_slot()[key, newkey], then slot check onkeyNone— no slot routing neededthe function is called once at the top of
execute(), before the main dispatch match. commands that don't need slot routing fall through the wildcard arm with zero overhead (just a pattern match, no async work).